<template>
  <div class="flex flex-between user_item bg_f" @click="goContact">
    <div v-if="realInfo&&realInfo.id">
      <p>
        <span>{{realInfo.name}}</span>
        <span>&nbsp;&nbsp;{{realInfo.phone}}</span>
        <span v-if="realInfo.type" class="defaultName">&nbsp;&nbsp;默认</span>
      </p>
      <p class="address">收货地址:&nbsp;{{realInfo.provinceName}} {{realInfo.cityName}} {{realInfo.address}}</p>
    </div>
    <div class="color" style=" text-align: center;" v-if="!realInfo.id&&pageType=='home'">
       请添加收货人
    </div>
    <div>
      <i class="address_right" v-if="pageType=='home'"></i>
    </div>
  </div>
</template>

<script>
export default {
  props:{
    info: {type:Object,default:{id:'',name:''}},
    // 页面类型
    pageType:{type:String,default:''}
  },
  data () {
    return {

    }
  },
  methods:{
    goContact(){
      if(this.pageType=='home'){
        if(!this.realInfo.id){
      this.$router.push('/pages/contact/detail/main?pageType='+this.pageType)
          return
        }
      this.$router.push('/pages/contact/main?pageType='+this.pageType)
      }else{
        let {query}=this.$route
        if(query&&query.pageType=='home'){
          this.$router.go(-1)
              this.$store.dispatch("setUserInfo",this.realInfo)
        }else{
         this.$router.push('/pages/contact/detail/main?id='+this.realInfo.id)
        }
      }
    }
  },
  computed:{
    realInfo(){
      let info=this.info
      console.log('改变',info)
      return info
    }
  },

}
</script>

<style scoped>
.card {
  padding: 10px;
}
.user_item{
  /* border: 1px solid #eee; */
  /* padding: 20px 10px; */

}
.address{
  color: #666;
  font-size: 14px;
  margin-top: 10px;
}
.defaultName{
  font-size: 12px;
  background-color: orange;
  display: inline-block;
  border-radius: 4px;
  text-align: center;
  padding:3px 10px 3px 8px;
  color: #fff;
  margin-left: 10px;
}
</style>
